﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class CMS_Control_SelUser : System.Web.UI.UserControl
{
    Usas.BLL.Cms.UsasDB udb = new Usas.BLL.Cms.UsasDB();
    private bool _IsOutCms = false;
    public bool IsOutCms
    {
        set
        {
            _IsOutCms = value;
        }
        get
        {
            return _IsOutCms;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            if (IsOutCms)
            {
                ImageButton1.Attributes.Add("onclick", "window.open ('../Cms/Role/SelEmployees.aspx', '员工搜索', 'height=500, width=500, toolbar=no, menubar=no, scrollbars=yes,status=no,top=200,left=300');return false;");
                txtJob.Attributes.Add("onmouseover", "this.readOnly=true");
                txtJob.Attributes.Add("onmouseout", "this.readOnly=false");
                hidJid.Value = "";
            }
            else
            {
                ImageButton1.Attributes.Add("onclick", "window.open ('../Role/SelEmployees.aspx', '员工搜索', 'height=500, width=500, toolbar=no, menubar=no, scrollbars=yes,status=no,top=200,left=300');return false;");
            }
            hidJid.Value = EmpName != "" ? EmployeeId : "";
            txtJob.Text = EmpName != "" ? EmpName : "";
        }

    }

    public string EmployeeId
    {
        get
        {
            return hidJid.Value;
        }
        set
        {
            hidJid.Value = value;
        }
    }

    public string EmpName
    {
        get
        {
            return txtJob.Text;
        }
        set
        {
            txtJob.Text = value;
        }
    }

    public void SelUserInti(string Eid, string Ename)
    {
        txtJob.Text = Ename;
        hidJid.Value = Eid;

        txtJob.Attributes.Add("onmouseover", "this.readOnly=true");
        txtJob.Attributes.Add("onmouseout", "this.readOnly=false");
        //txtJob.Enabled = false;
    }

    public void ReadOnly(string Eid)
    {



        DataSet  ds = udb.SelEmployees("Employees.EmployeeId=" + Eid);
        if(ds!= null)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                txtJob.Text = ds.Tables[0].Rows[0]["EmpName"].ToString();
            }
        }
        
        hidJid.Value = Eid;

        txtJob.Attributes.Add("onmouseover", "this.readOnly=true");
        txtJob.Attributes.Add("onmouseout", "this.readOnly=false");
    }

}
